/*********************************************************************
* File: compress.h
*
* \brief POD data compress routines based on LZSS.
*
* \author Instituto Superior Tecnico de Lisboa, Portugal
* \author Technical University of Lisbon, Portugal
* 
* \author Agentes Autonomos e Sistemas Multiagente
* \author Autonomous Agents and Multiagent Systems
* 
* \version	1.0
* \date		2006/2007
*********************************************************************/
#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <malloc.h>

#ifdef _MSC_VER
#pragma warning (disable: 4244) /* convert 'int' to 'unsigned char' */
#endif

namespace util{ namespace compress {
	/** 
	* \brief Size of ring buffer.
	**/
#define N		 4096	
	/** 
	* \brief Upper limit for match_length. **/
#define F		   18	
	/** 
	* \brief Encode string into position and length
	* if match_length is greater than this.
	**/
#define THRESHOLD	2   
	/** 
	* \brief Index for root of binary search trees.
	**/
#define NIL			N	

	//=============================================================================
	// Function Prototypes
	//=============================================================================
	void initializeTree(void);
	void insertNode(int r);
	void deleteNode(int p);
	int encode(char *filename, unsigned char* header, int headersize, unsigned char *buffer, int bufsize);
	int decode(char *filename, int headersize, unsigned char *buffer, int bufsize);
}}